# demo06_tuple.py
tuple01 = (1, 3, "hello", -10)
print(type(tuple01))  # 查看类型  <class 'tuple'>
# 如果一个元组中只有一个元素，那么创建该元组时，需要加上一个逗号，否则创建失败
tuple02 = ("world")
print(type(tuple02))  # 查看类型  <class 'str'>
tuple03 = ("world",)
print(type(tuple03))  # 查看类型  <class 'tuple'>
print(tuple01[0], tuple01[-1])  # 1 -10
print(tuple01[2:4])  # ('hello', -10)
print(tuple01.count("hello"))  # 1 统计某个元素在元组中出现的次数
print(tuple01.index(-10))  # 3 某个元素在元组中出现的位置，在列表同样适用
# tuple01[1] = 30  修改元素报错
# tuple01.append(10)  添加元素报错
for item in ("hello", 100, [1, 2,3], (4, 5, 6)):
    print("item:", item)
print("=================================")
for item in "hello world":
    print("item:", item)
print("=================================")
for item in ["hello", 100, [1, 2,3], (4, 5, 6)]:
    print("item:", item)